#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPixmap>
#include <QImage>
#include <QDesktopWidget>
#include <QTime>
#include <QTimer>
#include <QPaintEvent>
#include <QPainter>
#include <QByteArray>

#include <QTcpServer>
#include <QTcpSocket>
#include <QHostAddress>
#include <QNetworkInterface>
#include <QKeyEvent>
#include <iostream>
using namespace std;

#include "form.h"

#define MAXInterval 1000

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void paintEvent(QPaintEvent *);
    void keyPressEvent(QKeyEvent *ev);

    void calPic(QImage src);

    bool cmp_str(char str[], char substr[])
    {
        if(strlen(str)<strlen(substr))
            return false;
        for(int i=0;i<strlen(substr);i++)
        {
            if(str[i]!=substr[i])
            {
                return false;
            }
        }
        return true;
    }
    void recvMess(char data[]);

    void sendMess(QByteArray data);

    void sendImage(QImage img);

    void sendBytes(QByteArray buf);

private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void getScreen();

    void on_btn3_clicked();

private:
    Ui::MainWindow *ui;
    int px,py,pw,ph;
    QWidget *cutWidget;
    QImage pic;

    QTimer *timer;
    bool open;
    
    QTcpServer  *tcpServer;//监听套接字
    QTcpSocket  *tcpSocket;//通信套接字
    bool isConnect;

    bool startSend;

    int sendTimes;

    double SendInterval;
    double ImageScale;

    Form show1;
    bool isshowLine;

};

#endif // MAINWINDOW_H
